<template>
  <div>
    <div>
      <h3 id="title">添加电子账户</h3>
    </div>
    <Back></Back>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm"  label-width="100px" class="demo-ruleForm">
      <el-form-item label="账户类型" prop="a_type">
        <el-select v-model="ruleForm.a_type" placeholder="请选择账户类型">
          <el-option label="零钱" value="零钱"></el-option>
          <el-option label="零钱通" value="零钱通"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">添加账户</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import back from '@/components/back/Return';
import {addElEmail} from '@/api/info'
export default {
  name: "add",
  data() {
    return {
      ruleForm: {
        a_type: '',
      },
      rules: {
        a_type: [
          { required: true, message: '请选择账户类型', trigger: 'blur' },
          { min: 2, max: 20, message: '长度大于2', trigger: 'blur' }
        ]
      }
    };
  },
  methods: {
    //添加电子账户
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          addElEmail(this.ruleForm).then(respone=>{
            console.log(respone);
          }).catch(error=>{
            console.log(error);
          })
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  },
  components: {
    'Back': back
  }
}
</script>

<style scoped>
#title{
  line-height: 100px;
  text-align: center;
  color: #00a854;
}
</style>
